<div style="padding: 5px;">
				<ul id="deptStationTree" class="ztree"></ul>
			</div>
			<script type="text/javascript">
			var setting = {
				async: {
					enable : true,
					url : '${cxt!}/departmentStation/treeData',
					autoParam : ["id=ids"],//, "name=n", "level=lv"
					//otherParam : {"otherParam" : "zTreeAsyncTest"},
					type : "post"
				},
				view: {
					fontCss: getFont,
					expandSpeed: "",
					<% if(authUrl("/departmentStation/addStation")){ %>
					addHoverDom: addHoverDom,
					<% } %>
					removeHoverDom: removeHoverDom,
					selectedMulti: false
				},
				edit: {
					enable: true,
					<% if(!authUrl("/departmentStation/delStation")){ %>
					showRemoveBtn: false,
					<% } %> 
					<% if(!authUrl("/departmentStation/upStation")){ %>
					showRenameBtn: false,
					<% } %> 
					removeTitle: "删除岗位",
					renameTitle: "编辑岗位名称"
				},
				data: {
					simpleData: {
						enable: true
					}
				},
				callback: {
					onClick: stationTreeOnClick,
					beforeRemove: beforeRemove, //节点被删除之前的事件,并且根据返回值确定是否允许删除操作
					beforeRename: beforeRename, //用于捕获节点编辑名称结束

					beforeAsync: beforeAsync, //用于捕获异步加载之前的事件回调函数,zTree 根据返回值确定是否允许进行异步加载
					onAsyncSuccess: onAsyncSuccess, //用于捕获异步加载出现异常错误的事件回调函数
					onAsyncError: onAsyncError //用于捕获异步加载正常结束的事件回调函数
				}
			};
			
			function stationTreeOnClick(event, treeId, treeNode) {
				//重新初始化rightTree
				initStationRightTree(treeNode);
			};
	
			//字体设置
			function getFont(treeId, node) {
				return node.font ? node.font : {};
			}

			////////////////////下面是处理增删改节点//////////////////

			//节点被删除之前的事件,并且根据返回值确定是否允许删除操作
			function beforeRemove(treeId, treeNode) {
				var zTree = $.fn.zTree.getZTreeObj("deptStationTree");
				zTree.selectNode(treeNode);

				parent.$.messager.confirm('删除', '确认删除<' + treeNode.name + '>部门吗？',function(r){
					if(r){
						var url = "/departmentStation/delStation";
						var data = { "ids": treeNode.id};
						var reData = common_ajax.ajaxFunc(url, data);
						if(reData == "success"){
							zTree.removeNode(treeNode);
						}else{
							parent.$.messager.alert('删除',reData,'error');
						}
					}
					
				});
				return false;
				
			}
			
			//用于捕获节点编辑名称
			function beforeRename(treeId, treeNode, newName, isCancel) {
				if(treeNode.name == newName) {
					return true;
				} else if(newName.length == 0) {
					$.slideMsg("名称不能为空！", parent.$);
					return false;
				} else {
					var url = "/departmentStation/upStation";
					var data = { "ids": treeNode.id, "name": newName };

					var reData = common_ajax.ajaxFunc(url, data);
					if(reData == treeNode.id) {
						treeNode.name = newName;
						stationTreeOnClick(null, null, treeNode);
						return true;
					} else {
						$.slideMsg("修改<" + treeNode.name + ">岗位名称失败！", parent.$);
						return false;
					}
				}
			}

			//添加功能按钮
			function addHoverDom(treeId, treeNode) {
				var sObj = $("#" + treeNode.tId + "_span");
				if(treeNode.editNameFlag || $("#addBtn_" + treeNode.tId).length > 0 || $("#operatorBtn_" + treeNode.tId).length > 0) {
					return;
				}

				//1.处理添加按钮
				var addStr = "<span class='button add' id='addBtn_" + treeNode.tId + "' title='添加岗位' onfocus='this.blur();'></span>";
				sObj.after(addStr);
				var btn = $("#addBtn_" + treeNode.tId);
				if(btn) btn.bind("click", function() {
					var addName = "新增岗位"; //部门初始化名称
					var orderId = (treeNode.children == undefined ? 1 : (treeNode.children.length + 1));

					var url = "/departmentStation/addStation";
					var data = {
						"pIds": treeNode.id,
						"name": addName,
						"orderId": orderId,
						"level": treeNode.level
					};

					var reData = common_ajax.ajaxFunc(url, data);
					if(reData != "") {
						var zTree = $.fn.zTree.getZTreeObj("deptStationTree");
						zTree.addNodes(treeNode, { id: reData, pId: treeNode.id, name: addName });
						var node = zTree.getNodeByParam("id", reData, null); //根据新的id找到新添加的节点  
           		 		zTree.selectNode(node); //让新添加的节点处于选中状态  
           		 		stationTreeOnClick(null, null, node);
					} else {
						$.slideMsg("新增岗位失败！", parent.$);
					}
					return false;
				});
			};

			function removeHoverDom(treeId, treeNode) {
				//1.处理添加按钮
				$("#addBtn_" + treeNode.tId).unbind().remove();
				//2.处理查看按钮
				$("#operatorBtn_" + treeNode.tId).unbind().remove();
			};

			////////////////////下面是处理展开//////////////////

			//用于捕获异步加载之前的事件回调函数,zTree 根据返回值确定是否允许进行异步加载
			function beforeAsync() {
				curAsyncCount++;
			}

			//用于捕获异步加载出现异常错误的事件回调函数
			function onAsyncSuccess(event, treeId, treeNode, msg) {
				var deptStationTree = $.fn.zTree.getZTreeObj("deptStationTree");
				var nodes = deptStationTree.getNodes();
				deptStationTree.selectNode(nodes[0]);
				initStationRightTree(nodes[0]);
				
				curAsyncCount--;
				if(curStatus == "expand") {
					expandNodes(treeNode.children);
				} else if(curStatus == "async") {
					asyncNodes(treeNode.children);
				}

				if(curAsyncCount <= 0) {
					if(curStatus != "init" && curStatus != "") {
						//$("#demoMsg").text((curStatus == "expand") ? "全部展开完毕" : "后台异步加载完毕");
						asyncForAll = true;
					}
					curStatus = "";
				}
			}

			//用于捕获异步加载正常结束的事件回调函数
			function onAsyncError(event, treeId, treeNode, XMLHttpRequest, textStatus, errorThrown) {
				curAsyncCount--;

				if(curAsyncCount <= 0) {
					curStatus = "";
					if(treeNode != null) asyncForAll = true;
				}
			}

			var curStatus = "init",
				curAsyncCount = 0,
				asyncForAll = false,
				goAsync = false;

			function expandAll() {
				if(!check()) {
					return;
				}
				var zTree = $.fn.zTree.getZTreeObj("deptStationTree");
				if(asyncForAll) {
					//$("#demoMsg").text("已经异步加载完毕，使用 expandAll 方法");
					zTree.expandAll(true);
				} else {
					expandNodes(zTree.getNodes());
					if(!goAsync) {
						//$("#demoMsg").text("已经异步加载完毕，使用 expandAll 方法");
						curStatus = "";
					}
				}
			}

			function expandNodes(nodes) {
				if(!nodes) {
					return;
				}
				curStatus = "expand";
				var zTree = $.fn.zTree.getZTreeObj("deptStationTree");
				for(var i = 0, l = nodes.length; i < l; i++) {
					zTree.expandNode(nodes[i], true, false, false);
					if(nodes[i].isParent && nodes[i].zAsync) {
						expandNodes(nodes[i].children);
					} else {
						goAsync = true;
					}
				}
			}

			function asyncAll() {
				if(!check()) {
					return;
				}
				var zTree = $.fn.zTree.getZTreeObj("deptStationTree");
				if(asyncForAll) {
					//$("#demoMsg").text("已经异步加载完毕，不再重新加载");
				} else {
					asyncNodes(zTree.getNodes());
					if(!goAsync) {
						//$("#demoMsg").text("已经异步加载完毕，不再重新加载");
						curStatus = "";
					}
				}
			}

			function asyncNodes(nodes) {
				if(!nodes) {
					return;
				}
				curStatus = "async";
				var zTree = $.fn.zTree.getZTreeObj("deptStationTree");
				for(var i = 0, l = nodes.length; i < l; i++) {
					if(nodes[i].isParent && nodes[i].zAsync) {
						asyncNodes(nodes[i].children);
					} else {
						goAsync = true;
						zTree.reAsyncChildNodes(nodes[i], "refresh", true);
					}
				}
			}

			function reset() {//重置tree
				if(!check()) {
					return;
				}
				asyncForAll = false;
				goAsync = false;
				//$("#demoMsg").text("");
				$.fn.zTree.init($("#treeDemo"), setting);
			}

			function check() {
				if(curAsyncCount > 0) {
					//$("#demoMsg").text("正在进行异步加载，请等一会儿再点击...");
					return false;
				}
				return true;
			}

			//用于捕获节点被展开的事件回调函数
			function onExpand(event, treeId, treeNode) {
				if(treeNode === autoExpandNode) {
					className = (className === "dark" ? "" : "dark");
				}
			}

			function setTrigger() {
				var zTree = $.fn.zTree.getZTreeObj("deptStationTree");
				zTree.setting.edit.drag.autoExpandTrigger = $("#callbackTrigger").attr("checked");
			}

			//////////////////初始化////////////////////

			$(document).ready(function() {
				$.fn.zTree.init($("#deptStationTree"), setting);
			});

			setTimeout(function() {
				expandAll();
			}, 500);
		</script>